package cc.atliberty.creating.multiobject;

import java.util.Random;

/**
 * @Author 元宵
 * @url www.atliberty.cc
 * @Date 2023-10-30 18:47
 * @description: 骰子, 只能有两个
 */
public class Die {
    private static Die die1 = new Die();
    private static Die die2 = new Die();
    private Die() {}
    
    public static Die getInstance(int i) {
        if (i == 1) {
            return die1;
        } else {
            return die2;
        }
    }
    
    // 扔骰子
    public int dice() {
        int i = 0;
        Random random = new Random();
        i = random.nextInt();
        i = Math.abs(i);
        i = i % 6;
        i = i + 1;
        return i;
    }
}
